﻿<UserControl x:Class="GameListCreator.Controls.GameEditor"
             xmlns:my="clr-namespace:GameListCreator.Controls"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:GameListCreator.Converters"
             mc:Ignorable="d"             
             d:DesignHeight="600" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Margin="10" AllowDrop="True" Drop="LayoutRoot_Drop">

        <Grid.Resources>
            <converters:VisibilityConverter x:Key="VisibilityConverter"></converters:VisibilityConverter>
        </Grid.Resources>

        <Grid Visibility="{Binding HasSelectedGame, Converter={StaticResource VisibilityConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>

            <StackPanel>
            
            <DockPanel DockPanel.Dock="Top">

                <!--
            <my:RoundButton DockPanel.Dock="Right" Content="Remove" IconSource="../Images/Buttons/Delete.png" Opacity="0.5" Margin="5,0,5,0" />
            <my:RoundButton DockPanel.Dock="Right" Content="Add" IconSource="../Images/Buttons/Plus.png" Opacity="0.5" Margin="5,0,5,0" />
            -->

                <TextBlock Text="Edit game" Style="{StaticResource TitleForm}" />
            </DockPanel>

                <Expander Margin="5" Style="{StaticResource ExpanderStyle}" Padding="5,0,5,0" IsExpanded="False" BorderThickness="1" BorderBrush="DarkGray" Background="#6db7ff" Visibility="{Binding SelectedGame.IsChecked, Converter={StaticResource VisibilityConverter}, ConverterParameter=True}">
                    <Expander.Header>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                        
                            <Image Source="../Images/Buttons/Alert48.png" Width="32"></Image>
                        
                            <TextBlock Margin="5,5,5,5" Foreground="Black" Grid.Column="1" TextWrapping="Wrap" Text="There some information missing in this game. Please fill this information to have a compatible game."></TextBlock>
                            
                        </Grid>
                    </Expander.Header>

                    <TextBlock Margin="5,0,5,5" Foreground="White" Grid.Column="1" TextWrapping="Wrap" Text="{Binding SelectedGame.CheckMessage}"></TextBlock>

                </Expander>

            </StackPanel>
                
            <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">

                <Grid Grid.Row="1" Margin="10">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>

                    <StackPanel>

                        <!-- Rom -->

                        <TextBlock Foreground="DarkGray" Margin="0,2,0,2" Text="Rom Id :"></TextBlock>

                        <DockPanel>
                            <my:RoundButton DockPanel.Dock="Right" Margin="5,0,-5,0" IconSource="../Images/Buttons/Delete.png" Opacity="0.5" Click="ButtonRomDelete_Click"></my:RoundButton>
                            <my:RoundButton DockPanel.Dock="Right" Margin="5,0,-5,0" IconSource="../Images/Buttons/Dots.png" Opacity="0.5" Click="ButtonRomOpen_Click"></my:RoundButton>
                            <TextBox FontSize="16" IsReadOnly="True" Text="{Binding SelectedGame.Id, Mode=OneWay}"></TextBox>
                        </DockPanel>


                        <!-- GbDb path-->
                        <StackPanel Margin="0,2,0,2" Orientation="Horizontal" >
                            <TextBlock Margin="0,0,5,0" Foreground="DarkGray" Text="Vacuum GBDB Game Uri"></TextBlock>
                            <Button Content="http://www.gbdb.org" Click="OpenGbDbPage_Click" Cursor="Hand">
                                <Button.Template>
                                    <ControlTemplate TargetType="Button">
                                        <TextBlock Text="{TemplateBinding Content}" TextDecorations="Underline" Foreground="DodgerBlue"></TextBlock>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                        </StackPanel>

                        <DockPanel>
                            <my:RoundButton DockPanel.Dock="Right" Margin="5,0,-5,0" IconSource="../Images/Buttons/Refresh.png" Opacity="0.5" Click="ButtonVacuum_Click"></my:RoundButton>
                            <TextBox x:Name="TextBoxVacuum" FontSize="16"></TextBox>
                        </DockPanel>

                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <Grid Background="LightGray" Grid.Column="0" Margin="0,10,10,10" Height="100" Width="100">
                                <Image Stretch="UniformToFill" Source="{Binding SelectedGame.FrontCoverFullFilename}" ></Image>
                                <TextBlock Visibility="{Binding SelectedGame.FrontCoverFullFilename, Converter={StaticResource VisibilityConverter}, ConverterParameter=True}" Foreground="White" Text="Drag the cover" TextWrapping="Wrap" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                            </Grid>

                            <StackPanel Grid.Column="1" VerticalAlignment="Center">
                                <!-- Name -->
                                <TextBlock Foreground="DarkGray" Margin="0,2,0,2" Text="Name"></TextBlock>
                                <TextBox FontSize="16" Text="{Binding SelectedGame.Label, Mode=TwoWay}"></TextBox>
                                <!-- Publisher -->
                                <TextBlock Foreground="DarkGray" Margin="0,2,0,2" Text="Publisher"></TextBlock>
                                <TextBox FontSize="16" Text="{Binding SelectedGame.Publisher, Mode=TwoWay}"></TextBox>
                            </StackPanel>
                        </Grid>

                        <!-- Serie -->
                        <TextBlock Foreground="DarkGray" Margin="0,2,0,2" Text="Serie"></TextBlock>
                        <DockPanel>
                            <my:RoundButton DockPanel.Dock="Right" Margin="5,0,-5,0" IconSource="../Images/Buttons/Delete.png" Opacity="0.5" Click="ButtonRemoveSerie_Click"></my:RoundButton>
                            <my:RoundButton DockPanel.Dock="Right" Margin="5,0,-5,0" IconSource="../Images/Buttons/Plus.png" Opacity="0.5" Click="ButtonAddSerie_Click"></my:RoundButton>

                            <ComboBox FontSize="16" IsEditable="True" x:Name="ComboBoxSerie" SelectedItem="{Binding SelectedGame.Serie, Mode=TwoWay}" ItemsSource="{Binding Series}">
                            </ComboBox>
                        </DockPanel>

                        <!-- Genre -->
                        <TextBlock Foreground="DarkGray" Margin="0,2,0,2" Text="Genre"></TextBlock>
                        <ComboBox FontSize="16" IsEditable="True" Name="comboBoxGenre" SelectedItem="{Binding SelectedGame.Genre, Mode=TwoWay}" ItemsSource="{Binding Genres}">
                        </ComboBox>

                        <TextBlock Foreground="DarkGray" Margin="0,2,0,2" Text="Description"></TextBlock>
                    </StackPanel>

                    <Grid Grid.Row="1">
                        <!-- Description -->
                        <TextBox FontSize="16" AcceptsReturn="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" MinHeight="100" Text="{Binding SelectedGame.Description, Mode=TwoWay}" ></TextBox>
                    </Grid>
                </Grid>

            </ScrollViewer>
        </Grid>

    </Grid>
</UserControl>
